import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:part_time_job_pro/common/style/theme.dart';
import 'package:part_time_job_pro/common/widgets/custom_appbar.dart';

import 'logic.dart';
import 'state.dart';

class LangSettingPage extends StatelessWidget {
  LangSettingPage({super.key});

  //路由地址
  static const String routeName = "/lang_setting";
  final LangSettingLogic logic = Get.find<LangSettingLogic>();
  final LangSettingState state = Get.find<LangSettingLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFF7F9FF),
      appBar: CustomAppBar.customAppBar(title: "语言设置"),
      body: Container(
        padding: const EdgeInsets.only(top: 10),
        child: ListView.separated(
          itemBuilder: (context, index) {
            return Container(
              padding: const EdgeInsets.only(left: 16, right: 16),
              color: Colors.white,
              height: 50,
              child: InkWell(
                onTap: () {
                  logic.changeLanguage(index);
                },
                child: Row(
                  children: [
                    Expanded(child: Text(state.langList[index])),
                    Visibility(
                      visible: state.currentLanguageIndex.value == index,
                      child: const Icon(Icons.check_rounded, color: Colors.blue),
                    ),
                  ],
                ),
              ),
            );
          },
          separatorBuilder: (context, index) {
            return Container(height: 2, color: Colors.white70);
          },
          itemCount: state.langList.length,
        ),
      ),
    );
  }
}
